trigger:
  batch: true
  branches:
    include:
    - release/*.*
    exclude:
    - release/6.0*
  paths:
    include:
    - '*'
    exclude:
    - '**.md'
    - eng/Version.Details.xml
    - .devcontainer/*
    - .github/*
    - docs/*
    - LICENSE.TXT
    - PATENTS.TXT
    - THIRD-PARTY-NOTICES.TXT

schedules:
  - cron: "0 7,19 * * *" # run at 7:00 and 19:00 (UTC) which is 23:00 and 11:00 (PST).
    displayName: Runtime-community default schedule
    branches:
      include:
      - main
    always: false # run only if there were changes since the last successful scheduled run.

variables:
  - template: /eng/pipelines/common/variables.yml

extends:
  template:  /eng/pipelines/common/templates/pipeline-with-resources.yml
  parameters:
    stages:
    - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
      - stage: EvaluatePaths
        displayName: Evaluate Paths
        jobs:
          - template: /eng/pipelines/common/evaluate-default-paths.yml

    - stage: Build
      jobs:

      #
      # s390x & PPC64 little endian
      # Build the whole product using Mono and run libraries tests
      #
      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/common/global-build-job.yml
          helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml
          buildConfig: Release
          runtimeFlavor: mono
          platforms:
          - linux_s390x
          - linux_ppc64le
          variables:
            # map dependencies variables to local variables
            - name: librariesContainsChange
              value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_libraries.containsChange'] ]
            - name: monoContainsChange
              value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_mono_excluding_wasm.containsChange'] ]
          jobParameters:
            testGroup: innerloop
            nameSuffix: AllSubsets_Mono
            buildArgs: -s mono+libs+host+packs+libs.tests+clr.iltools+clr.packages -c $(_BuildConfig) /p:ArchiveTests=true
            timeoutInMinutes: 180
            condition: >-
              or(
                eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_libraries.containsChange'], true),
                eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_mono_excluding_wasm.containsChange'], true),
                eq(variables['isRollingBuild'], true))
            # extra steps, run tests
            postBuildSteps:
              - template: /eng/pipelines/libraries/helix.yml
                parameters:
                  creator: dotnet-bot
                  testRunNamePrefixSuffix: Mono_$(_BuildConfig)
                  condition: >-
                    or(
                    eq(variables['librariesContainsChange'], true),
                    eq(variables['monoContainsChange'], true),
                    eq(variables['isRollingBuild'], true))

      #
      # Build the whole product using Mono
      #
      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/common/global-build-job.yml
          helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml
          buildConfig: Release
          runtimeFlavor: mono
          platforms:
          - freebsd_x64
          variables:
            # map dependencies variables to local variables
            - name: librariesContainsChange
              value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_libraries.containsChange'] ]
            - name: monoContainsChange
              value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_mono_excluding_wasm.containsChange'] ]
          jobParameters:
            testScope: innerloop
            nameSuffix: AllSubsets_Mono
            buildArgs: -s mono+libs+host+packs -c $(_BuildConfig)
            timeoutInMinutes: 120
            condition: >-
              or(
                eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_libraries.containsChange'], true),
                eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_mono_excluding_wasm.containsChange'], true),
                eq(variables['isRollingBuild'], true))

      #
      # Build the whole product using Mono and run libraries tests
      #
      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/common/global-build-job.yml
          helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml
          buildConfig: Release
          runtimeFlavor: mono
          platforms:
          - linux_armv6
          variables:
            # map dependencies variables to local variables
            - name: librariesContainsChange
              value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_libraries.containsChange'] ]
            - name: monoContainsChange
              value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_mono_excluding_wasm.containsChange'] ]
          jobParameters:
            testScope: innerloop
            nameSuffix: AllSubsets_Mono
            buildArgs: -s mono+clr.iltools+clr.packages+libs+host+packs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true
            timeoutInMinutes: 120
            condition: >-
              or(
                eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_libraries.containsChange'], true),
                eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_mono_excluding_wasm.containsChange'], true),
                eq(variables['isRollingBuild'], true))
            ${{ if eq(variables['isRollingBuild'], true) }}:
              # extra steps, run tests
              postBuildSteps:
                - template: /eng/pipelines/libraries/helix.yml
                  parameters:
                    creator: dotnet-bot
                    testRunNamePrefixSuffix: Mono_$(_BuildConfig)
